package com.clip.util.mobile;

import java.io.InputStream;
import java.util.Properties;

public class MobileEnv extends Properties {
	private static MobileEnv instance;
	
	public static String ENTID="entid";
	public static String UID="uid";
	public static String PWD="pwd";
	public static String URL="url";
	public static String RETURNFLAG="returnflag";
	public static String METHOD="method";
	
	private MobileEnv(){
		InputStream is = this.getClass().getResourceAsStream("/MobileInfo.properties");
		try{
			this.load(is);
		}catch(Exception e){
			System.err.println("读取属性文件是遇到错误！");
			e.printStackTrace();
		}
	}
	private static synchronized void makeInstance(){
		if(instance == null){
			instance = new MobileEnv();
		}
	}
	public static MobileEnv getInstance(){
		if(instance != null){
			//实例已被创建时将直接返回当前实例
			return instance;
		}else{
			//实例还没有被创建则新建properties实例对象
			makeInstance();
			return instance;
		}
	}
	
	public static String getMobileConfigByKey(String key){
		MobileEnv mobileEnv=getInstance();
		return (String) mobileEnv.get(key);
	}
}
